Method for determination of focal length for a zoom lens

ABSTRACT

A method and apparatus for determining a focal-length setting of a lens mounted to a camera is disclosed. In a method for determining a focal-length of a lens mounted to a camera, a distorted image of a scene is captured. A distortion-correction function is applied on the distorted image or on a portion of the distorted image. A most representative distortion-correction function is identified and a current focal-length setting for the lens is identified by correlating the identification to a data compilation.

FIELD OF INVENTION

The present invention relates to a method for determining focal length.

BACKGROUND

Every lens system introduces various types of optical artifacts, and thepresent disclosure relates to geometric distortions or rather thedetermination and utilization thereof.

A common type of geometric distortion in an imaging system including azoom lens is barrel distortion. Barrel distortion manifests itself inthat the magnification decreases with distance from the optical axis,barrel distortion is categorized as a radial distortion, as ispincushion distortion and moustache distortion. The effect of barreldistortion may be that a rectangular object with four straight edges asimaged will obtain a barrel-like shape where the edges are convex, hencethe name.

Depending on the specification for the lens and the zoom settings thegeometric distortion may be more or less pronounced. The aperture of thecamera affects the quality of the image and the optimum aperture isdepending on the focal length. In order to have a zoom lens operate atthe sweet spot where the imaging system is optimized on image qualitythe aperture has to be adjusted according to the present focal length,and consequently continuously updated information on the present focalsetting is of value. Some lenses uses feedback from zoom motors in orderto keep track of the present focal length. However, there are also zoomlenses that do not have this feature, e.g. lenses where the zoomsettings are made manually and other zoom lenses where there is nofeedback function. The category “zoom lenses” is typically divided intovarifocal lenses and parfocal lenses and for the purposes of the presentdisclosure the word “zoom lens” will mainly be used and zoom setting andfocus setting or focal length setting will be used in parallel.

SUMMARY

A method for determining focal-length setting of a lens mounted to acamera, comprises: capturing a distorted image of a scene andidentifying edges in the image by means of an edge-detection algorithm.For at least a fraction of the identified edges functions describingthem are identified. The identified functions, or a selection and/orcombination of the identified functions, are compared with a datarelating to the characteristics of the lens. The data may comprisetransformation data correlating a distortion-correction function with anumber of focal-length settings for the lens is used to identify afocal-length setting which is related to the identified functions, orthe selection and/or the combination of the identified functions.

By using the method a value for the present focal-length setting may beextracted from image data contained in a distorted image, and used forany desired purpose. It may be important to note that in most cases oneand the same distortion-correction function will describe the distortionfor the entire image (for each focal-length setting), and a greaternumber of edges evaluated may increase the precision and accuracy in theidentification process.

In one or more embodiments the step of identifying functions isperformed on edges identified in the distorted image while in adistorted format. Typical appearances for a barrel-distortion is thatlines or edges that should have been straight get a curved appearance inthe distorted image, and the curved edges are well-suited for curvefitting. The fact that the barrel distortion (in effect the curvature ofthe lines) will increase with the distance from the optical axis mayresult in that the lines further away from the optical axis may be usedto identify functions with better accuracy and precision.

In one or several embodiments the step of identifying functions is basedon fitting of the distortion-correction functions available in thetransformation data, i.e. selected among the distortion-correctionfunctions describing the characteristics of the lens. The identificationmay be performed in several different ways. In most embodiments there isa desire to conform the functions evaluated in a fit to at least theformat of the functions to be compared with at a later stage, in orderfor the result of the fit to be usable. In the present embodimenthowever the distortion correction functions used are limited to the onespresent in the data relating to the characteristics of the lens. Theprocess of finding the best fit the identification process may followany suitable optimization algorithm.

In one or several embodiments a distortion correction is performedbefore or as a step in identifying the best fit. After adistortion-correction function is applied on the distorted image anamount of straight edges is identified. Following that a newdistortion-correction function is applied, and the amount of straightedges is identified. By iterating the process for various distortioncorrection functions present in the data the most fitting distortioncorrection function may be identified. Again, any suitable optimizationalgorithm may be used for the process. It may or may not be preferableto use the whole image in the evaluation. An alternative may be to onlyuse portions of the image, e.g. a portion identified as a foreground, orportions comprising objects having edges, or merely the edges or afraction of the edges identified in the edge detection.

The distortion-correction function may be a polynomial of degree 5 orless, such as 4, 3, 2, or 1. A polynomial of degree 3 may be preferredsince it may be complex enough to describe the distortion yetnon-complex enough to enable a swift identification process.

The data relating to the characteristics of the lens may comprise amapping of polynomials or other functions and correlated focal-lengthsettings for the lens.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a schematic block view of a camera head;

FIG. 2 is an image displaying barrel distortion;

FIG. 3 is the image of FIG. 2 after a distortion-correction function hasbeen applied;

FIG. 4 is a flow chart of a first embodiment of the present invention;and

FIG. 5 is a flow chart of a second embodiment of the present invention.

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

Every lens introduces geometric distortions in the scene captured. In azoom lens the geometric distortion varies for different focal lengths.Barrel distortion is one form of geometric distortion introduced in wideangle lenses. The amount of geometrical distortion of a fixed focallength lens depends on the distance from the centre of the lens, i.e.radius. In a zoom lens, as for any other lens or lens system, thegeometrical distortion is a function of the distance from the centre ofthe lens, for each focal length setting. A general rule of thumb is thatthe shorter the focal length setting of the zoom lens the greater thedistortion. The geometrical distortion may thus be described as afunction of the radius, r, and in some sense the focal length, f. Foreach focal length the geometric distortion will vary with the radiusaccording to a specific function.

One idea of the present disclosure is to utilize this dependence in amethod for finding the present focal length setting of a lens. This maybe performed by means of analyses based on the geometrical distortion,which will be described in some more detail in the following.

FIG. 1 is a block diagram of a camera head as used in a severalembodiments of the present invention. The camera 10 has a lens 14 (a setof lenses, an objective, etc.) projecting the light from an area to beimaged onto an image sensor 16. The information from the image sensor 16is processed in an image processor 18 which may or may not form a partof central processing unit 20. The image processor 18 may in one or moreembodiments communicate with a volatile memory 22, which may alsocommunicate with the central processing unit 20. A non-volatile memory24 may be arranged to communicate with the CPU 20 is a normal fashion.The video camera may also comprise a network interface 26 forcommunication within a network. The lens 14 is a zoom lens. The zoomlens is set manually and there may be no logging of current zoomsettings.

FIG. 2 is a schematic imaged view of a scene including a building 30, alamppost 32, a group of trees 34 and a horizon 36. The object as such isnot essential, yet the effect of barrel distortion is exemplified by thecurved lines that should have been straight. Each object may contain anumber of lines that should have been straight. Note that the distortionin the imaged scene is not modelled, rather it is merely for explanatorypurposes. Also, even though objects in the scene are mere examples it isquite typical that the straight lines have a higher representation inmanmade objects (the house, elements of the house and the lamppost). Ina typical monitoring application for a video camera, e.g. a surveillanceapplication, a scene would include man-made objects, and by that a sceneto be captured would include straight lines. For that reason the presentdisclosure may be particularly relevant for such a monitoringapplication.

In FIG. 3 a distortion-correction function has been applied. Again, theimage is for explanatory purposes only. After application of thedistortion-correction function lines that are supposed to be straighthave been straightened, and the effect of a varying magnification in thedistorted image is that the frame of the corrected image obtains apincushion shape. Distortion correction functions may have differentcomplexities, and depending on e.g. input data some or other distortionsmay prevail after distortion correction as well.

As for the correction function the general approach may be to use apolynomial of n:th degree. In the below equation R_(u) denotes acorrected, undistorted radius being a function of the distorted radiusr_(bd). The constant k_(n) is a constant that may be deduced in aprocess of fitting the function to a curve.R _(u)(r _(bd))_(f) =k ₀ +k ₁ r _(bd) +k ₂ r _(bd) ² +k ₃ r _(bd) ³ +k ₄r _(bd) ⁴ +k ₅ r _(bd) ⁵+ . . .  [eq. 1]

In a simplified approach, which usually is considered acceptable, allconstants but for k₀, k₁ and k₃ are set to zero, such that:R _(u)(r _(bd))_(f) =k ₀ +k ₁ r _(bd) +k ₃ r _(bd) ³  [eq. 2]

By setting the coordinate system appropriately k₀ may be set to zero aswell. In other embodiments polynomials of other orders may be used, andin still other embodiments other function may be used instead.

Once an appropriate form for the polynomial is selected a database or acompilation of data may be built. This is exemplified by the first stepin the flowchart of FIG. 4 and FIG. 5. The dotted line from the step ofmapping correction polynomials to the subsequent step is meant toindicate that the mapping and generation of characteristics data isgenerally performed as a separate step, not near in time or even spacewith the subsequent step of acquiring an image. Such data may beprovided by a camera manufacturer, a lens manufacturer, another serviceprovider, a group of users etc. Some manufactures provide such dataalready today, e.g. for the purpose of allowing for users to perfectacquired pictures in a post-production process. The data as such may beimportant for the function of the method, but details of the creation ofthe compiled data may not be as important.

When compiling the data (performing the mapping) for a particular lensor lens combination a set of values for the constants k_(i) of thepolynomial will be associated with each zoom setting or focal length.The result is that for a finite number of discrete settings of zoom orfocal length there will be a set of values for the constants k_(i); k₀,k₂ and k₃ as for the simplified equation eq. 2. When possible such setsmay be expressed as functions themselves such that their values forintermediate focal lengths may be interpolated as well.

In a practical situation the data may be compiled once for each lens,but it may also be compiled once for each type of lens or lens system.Any subsequent user of the data may then download the data, and/or thedata may be included in a non-volatile memory of the camera system.

FIG. 4 is a flow chart illustrating a first embodiment. The firstoperation is to form the data 40, which has been discussed already. Thecombined data may in one or more embodiments take the form of afunction, which in certain applications may be advantageous andeffective. The distortion-correction functions do not have to bepolynomials, though it is a common form.

In the next step 42 an image is acquired and analysis may be initiated,and in this first embodiment the analysis is initiated with identifying44 elongate edges in the distorted image, since the elongate edges areprobable candidates to be transformed to straight lines afterapplication of the distortion-correction function. Edges may be foundusing any existing edge-detection algorithm.

After having identified and localized the edges, polynomials, or otherfunctions for that matter, may be fitted 46 to the elongate edges.Fitting functions to a set of points located in an image may also bedone in several different ways. A straight-forward fitting andevaluation using a least square method may be used, and a transform toparameter space and solution using a Hough transform may be used aswell. Depending on the situation some fitting methods may be moresuitable than others, and the selection of the which fitting method touse is a straightforward operation for the skilled person. When thepolynomials are identified the results in terms of the resultingconstants k_(i) may be compared. Even if it may be superfluous tomention it, the form of the polynomials may preferably be the same asfor the polynomials used when the data was compiled in order for theresult of the fitting to be usable and to add a guiding constraint tothe solution process.

After fitting of the polynomials to curved lines of the distorted image,and having identified a best fit in step 48, the values for theconstants k_(i) may be used to for comparison with the data in step 50.From the comparison the best fit may be selected and the data associatedwith that particular fit may be identified. One output derived from themethod may be the current focal-length setting for the lens system (step52). The focal length is a property that may be usable in severalprocesses, the optimization of the aperture being mentioned in thebackground section. Some further examples include optimization ofexposure settings, image stabilisation (minimization of the effect ofvibration and shake), and the mere ability to present the focal-lengthsetting to a user for the user to utilize in any other way, to mention afew.

The flow chart of FIG. 5 illustrates a second embodiment, in which moreof a global view is applied. Again an image of a scene is acquired (step42), the image displaying a distortion such as a barrel distortion. Theselection criterion comprises an iterative process, which as such issimilar to the selection criterion previously described, yet thedistortion-correction functions stored in the compilation of data areused in a more direct fashion. The iterative process comprises applyinga distortion-correction function (step 54) for a particular focal lengthon the distorted image. The corrected image, which has been corrected“blindly” may still be distorted, and is likely to be. The next actionis therefore to evaluate the corrected image, in step 56. In one examplea straight-edge detection is performed, and in other examples one of thealready mentioned techniques may be used. It may be mentioned yet againthat the polynomials or transformation functions used to describe thedistortions for the particular lens and for various focus settingthereof may be, and often is, known. Using this input as further aconstraint and effectively limiting the space available for solutions,may further accelerate an analysis.

If a straight-edge detection is used, a measure of the amount ofstraight edges in the corrected image is deduced, enabling forcomparison between images. One assumption may be that the higher theamount of straight edges, the better the correction. In a subsequentstep another distortion-correction function for another focal length isapplied, and following the straight-line detection the new measure ofthe amount of straight lines in the corrected image deduced. The newvalue is compared to the previous value (or several previous values) andmay be deduced if the correction was for the better or for the worse.The process is then iterated until an optimal fit is achieved (see step58). There are several optimization algorithms that may be used, some ofwhich have been mentioned already. In all and any embodiments mentionedthe evaluation may be performed on portions of an image rather than theentire image. The order of events in the process may be modified inrelated embodiments, and instead of making comparisons as a step in theiterative process the comparison may be performed after all availabledistortion functions have been applied, after which the selectioncorresponds to finding an extreme value (maximum or minimum) in a set ofdata. The output will still be a value for the focal-length setting instep 52.

When only portions of the image are evaluated rather than the entireimage these portions may be user selected or identified by means ofimage analysis. An example could be that if an object has beenidentified as an object having straight edges (such as a building) itcould be selected as one of the portions to be used, while if an objectis identified as an object not expected to have straight edges (such asa human) it could be removed from the portions to be evaluated.Furthermore, various portions of the image may be given differentweights in the evaluation. One example could be that since the effectsof distortion will increase with distance from the optical axis edgesbeing further away from the optical axis may be given a greater weight.

Again, the output may be a value of the current focal-length settingsfor the particular lens or lens system.

In an alternative approach, which could be defined as a thirdembodiment, the global optimization is performed on the localizedelongated edges only. Such an embodiment would imply that in firstembodiment, when the elongate edges have been detected, the selectioncriterion of the second embodiment is applied. Therefore, in aniterative optimization process the best fitting polynomial is found andin each step of the iterative process the “amount” of straight lines isquantified. It may be said that other optimization processes or fittingprocesses may be used.

Any of the embodiments of the present disclosure may be applied to animaging system having a zoom lens or lens system. The embodiments areparticularly useful for calibrating or identifying the current focallength setting for zoom-lens system. At the same time the optimaldistortion correction will be identified, at least within theconstraints of the compiled data and the use thereof.

In a monitoring system a method according to the present disclosure maybe useful, in particular if the lens system used is of a type includinga zoom lens or a varifocal lens where the current settings are nottracked in any way. For such a monitoring system the method may beapplied upon request by an operator or as a step in an initiation orcalibration process. Even if possible, there is no apparent need orbenefit for the method to run continuously. A focal-length setting andan optimal distortion correction have been identified, and a newidentification is not necessary until a change has occurred.

Furthermore, though “zoom”, “zoom settings”, “focal length” and “focallength setting” etc. have been used throughout the present descriptionthe output from the method may equally well be another measure orparameter through which the named parameters may be deduced.

There are several approaches that may be used to deduce the mostrepresentative distortion-correction function, and the order of actionsmay differ from those presented in relation to the embodiments.

In this context a general comment applying to all embodiments may bethat the compiled data does not have to contain thedistortion-correction functions as such. It may instead containinformation which in turn may be used to identify thedistortion-correction function. One example could be that the dataincludes any constants used by the distortion-correction function, whilethe basic form of the distortion-correction function is storedelsewhere. From a practical standpoint this does not matter, though fromthe viewpoint of optimizing information logistics different concepts maybe used in different situations. The present disclosure does not requireany limitation in this respect in order to be applicable.

What is claimed is:
 1. A method for determining a focal-length settingof a lens mounted to a camera, said method comprising: capturing animage of a scene through the lens, which introduces distortion to thecaptured image; identifying edges in the image, by means of anedge-detection algorithm; identifying functions describing at least afraction of the identified edges; comparing the identified functions ora selection and/or combination of the identified functions with a datacompilation for the lens, wherein the data compilation comprisestransformation data correlating a distortion-correction function with anumber of focal-length settings for the lens; and identifying, by use ofthe data compilation, a focal-length setting which is related to theidentified functions or the selection and/or the combination of theidentified functions.
 2. The method of claim 1, wherein the identifyingof functions is performed on edges identified in the distorted imagewhile in a distorted format.
 3. The method of claim 1, wherein theidentifying of functions is based on fitting of thedistortion-correction functions available in the transformation data. 4.The method of claim 1, wherein the identifying of functions is based onfitting of the distortion-correction functions available in thetransformation data comprising: applying distortion-correction functionson the distorted image or portions thereof; evaluating the amount ofstraight lines in the image or portions thereof; identifyingdistortion-correction function resulting in the maximum amount ofstraight lines; and identifying the focal-length setting correspondingto the identified distortion correction function.
 5. The method of claim3, wherein the identifying of functions is performed on the identifiededges or a subselection thereof only.
 6. The method of claim 1, whereinthe distortion-correction function is a polynomial of degree 5 or less.7. The method of claim 6, wherein the distortion-correction function isa polynomial of degree 4 or less.
 8. The method of claim 6, wherein thedistortion-correction function is a polynomial of degree 3, 2, or
 1. 9.The method of claim 1, wherein the identifying of functions utilizes aniterative mathematical optimization technique.
 10. The method of claim1, wherein the data compilation comprises a mapping of polynomialscorrelated focal-length settings for the lens.
 11. A camera forperforming the method of claim 1, the camera comprising an imageprocessor, wherein the processor is configured to identify edges in anacquired image by application of one or more edge-detection algorithmsand to identify functions describing at least a fraction of theidentified edges, the camera further comprising a storage areacontaining a data compilation relating to transformation datacorrelating a distortion-correction function with a number offocal-length settings for a zoom lens mounted to the camera, and beingconfigured to identify, by use of the data compilation and theidentified functions or a selection and/or combination of the identifiedfunction, a current focal-length setting of the zoom lens which isrelated to the identified functions, or the selection and/or thecombination of the identified functions.